﻿/// Write a program that finds the maximal sequence of equal elements in an array.
///	Example: {2, 1, 1, 2, 3, 3, 2, 2, 2, 1}  {2, 2, 2}.


using System;

class zad4
{
    static void Main()
    {
        int[] arr = { 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 5 };

        int sequenceLenght = 1;
        int sequenceBestLenght = 1;
        int sequenceValue = arr[0];
        int bestSeqenceValue = arr[0];

        for (int i = 0; i < arr.GetLength(0)-1; i++)
        {
            if (arr[i]==arr[i+1])
            {
                sequenceValue = arr[i];
                sequenceLenght++;

                if (sequenceLenght > sequenceBestLenght)
                {
                    sequenceBestLenght = sequenceLenght;
                    bestSeqenceValue = sequenceValue;
                }
                
            }
            else
            {
                sequenceLenght = 1;
            }
        }

        Console.WriteLine("maximal sequence is {0} for number {1}", sequenceBestLenght, bestSeqenceValue);
    }
}
